#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <string.h>
#include <arpa/inet.h>
#define SIZE 256
int main (int argc,char* argv[])
{
	int PORT = 9600;
	int len_client = 0,len_server = 0,n;
	int sockfd=0 ;
	struct sockaddr_in client, server;
	
	
	// ouvrir le socket du serveur
	sockfd = socket(AF_INET,SOCK_DGRAM,0);
	bzero(&server,sizeof(server));
	// remplir l'adresse local du serveur
	server.sin_family = AF_INET;
	server.sin_port = PORT;
	server.sin_addr.s_addr = inet_addr("127.0.0.1");
	
	len_server = sizeof (server);
	
	bind(sockfd, (struct sockaddr *)(&server), len_server);	
		
	while(1)
	{
	char cl[1000];
	bzero(cl, 1000);
	//Attente message 
	len_client = sizeof(client);
	n = recvfrom(sockfd,cl,1000,0,(struct sockaddr *)&client,(socklen_t *)&len_client);
	sendto(sockfd,cl,n,0,(struct sockaddr *)&client,sizeof(client));
	//printf("alooooooooooooooooohahahhaha:\n");
	//printf("%s",cl);
	//printf("succeeesssssssssssssssssssssssssss");
	}
	
	return 0;
}
